package com.u.social.search.controller;

import com.u.social.search.model.ArticleDTO;
import com.u.social.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: u-social
 * @description: 搜索控制器
 * @author: Alex Wu
 * @createDate: 2025-04-11 11:13
 **/

@RestController
public class SearchController {

    @Autowired
    private SearchService searchService;


    /**
     * 搜索
     * @param keyword
     * @return
     */

    public List<ArticleDTO> searchByKeyword(String keyword) {
        List<ArticleDTO> articleDTOS = searchService.search(keyword);
        return articleDTOS;
    }

    /**
     * 搜索联想词
     *
     * @param keyword 关键词
     * @return 是否成功
     */
    public List<ArticleDTO> searchAssociationalWord(String keyword) {
        System.out.println("搜索关键词：" + keyword);
        List<ArticleDTO> articleDTOS = searchService.searchAssociationalWord(keyword);
        return articleDTOS;
    }

    public List<String> searchHotWord() {
        List<String> hotWords = searchService.searchHotWord();
        return hotWords;
    }


}
